//
//  InputBeesKeyViewController.m
//  Bees
//
//  Created by NowYouCanSee on 2019/1/4.
//  Copyright © 2019 xiaohan. All rights reserved.
//

#import "InputBeesKeyViewController.h"

@interface InputBeesKeyViewController ()

@end

@implementation InputBeesKeyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = XLocalized(@"导出私钥");
    UIView *backV = [UIView new];
    backV.backgroundColor = UIColorHex(#F7F7F7);
    backV.layer.cornerRadius = AdaptedWidth(10);
    [self.contentView addSubview:backV];
    [backV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kNormalSpace);
        make.right.mas_equalTo(-kNormalSpace);
        make.top.mas_equalTo(AdaptedHeight(30));
        make.height.mas_equalTo(AdaptedWidth(134));
    }];
    
    UILabel *keyLab = [UILabel new];
    [backV addSubview:keyLab];
    keyLab.font = kDefaultFont(16);
    keyLab.textColor = UIColorHex(666666);
    keyLab.numberOfLines = 0;
    [keyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.centerY.mas_equalTo(0);
        make.left.mas_equalTo(kNormalSpace);
        make.right.mas_equalTo(-kNormalSpace);
    }];
    keyLab.text = self.private_key;
    
    UIButton *copyBtn1 = [UIButton new];
    [backV addSubview:copyBtn1];
    [copyBtn1 setImage:IMAGE_NAMED(@"copy_black") forState:UIControlStateNormal];
    [copyBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.right.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(35, 35));
    }];

    [copyBtn1 addTapBlock:^(UIButton * _Nonnull btn) {
        if (keyLab.text.length) {
            UIPasteboard *pab = [UIPasteboard generalPasteboard];
            [pab setString:keyLab.text];
            if (pab == nil) {
                [self.view makeToast:XLocalized(@"复制失败!")];
            }else
            {
                [self.view makeToast:XLocalized(@"复制成功!")];
            }
        }
    }];
    
    XThemeFlatButton *btn = [XThemeFlatButton button];
    [btn setTitle:XLocalized(@"完成") forState:UIControlStateNormal];
    [self.contentView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(backV.mas_bottom).offset(AdaptedHeight(90));
        make.left.mas_equalTo(kNormalSpace);
        make.right.mas_equalTo(-kNormalSpace);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(AdaptedWidth(40));
    }];
    kWeakSelf(self);
    [btn addTapBlock:^(UIButton * _Nonnull btn) {
        [weakself.navigationController popViewControllerAnimated:YES];
    }];
}

@end
